package com.masterclient.app.modules.firstpager.fragments.contract;

import com.eoner.baselib.presenter.ThrowableConsumer;
import com.masterclient.app.httpservice.RetrofitUtil;
import com.eoner.baselibrary.bean.firstpager.VideoBrandBean;

import io.reactivex.Observable;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

/**
* Created by TMVPHelper on 2017/08/11
*/
public class VideoBrandPresenter extends VideoBrandContract.Presenter{


    @Override
    public void getVideoBrand() {
        Observable<VideoBrandBean> observable = RetrofitUtil.getInstance().getVideoBrands();

        Disposable disposable = toSubscribe(observable, new Consumer<VideoBrandBean>() {
            @Override
            public void accept(@NonNull VideoBrandBean bean) throws Exception {
                if("0".equals(bean.getCode())){
                    mView.showVideoBrands(bean.getData());
                }
            }
        }, new ThrowableConsumer());

        mRxManager.add(disposable);
    }
}